import time,random

def product():
    while True:
        time1 = time.sleep(random.randint(1, 2))
        num = yield
        print("生产商品",num)
        return num


def consumer():
    while True:
        time.sleep(random.randint(3, 5))
        pro = yield from product()
        print("获取商品",pro)

def start():
    c = consumer()
    next(c)
    num = 0
    while True:
        num += 1
        c.send(num)

start()